package com.rutas.java;

import java.util.ArrayList;

import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;

public class UpdateHandler extends DefaultHandler {
	private StringBuffer buffer;
	private ArrayList<String> tuplas;
	private boolean columna;
	
	public ArrayList<String> getDatos(){
		return tuplas;
	}
	
	@Override
	public void startDocument (){
		buffer = new StringBuffer();
		tuplas = new ArrayList<String>();
		columna = false;
	}
	
	@Override
	public void endDocument(){
		
	}
	
	@Override
	public void startElement (String uri, String localName, String qName, Attributes attributes){
		if (localName.equals("column")){
			buffer.setLength(0);
			columna = true;
		}
	}
	
	@Override
	public void endElement (String uri, String localName, String qName){
		if (localName.equals("column")){
			String campo = "";
			campo += buffer.toString();
			columna = false;
			tuplas.add(campo);
		}
	}
	
	@Override
	public void characters (char[] ch, int start, int length){
		if (columna)
			buffer.append(ch, start, length);
	}
}